package com.example.activityforresult;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity implements OnClickListener{
	private EditText et_phonenumber;
	private Button btn_getmen;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		et_phonenumber=(EditText) findViewById(R.id.et_phonenumber);
		btn_getmen=(Button) findViewById(R.id.btn_getmen);
		
		btn_getmen.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		Intent intent = new Intent(MainActivity.this,ResultActivity.class);
		startActivityForResult(intent, 0);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(data == null) {
			return;
		}
		Bundle bundle=data.getExtras();
		String number=bundle.getString("telephoneNum");
		et_phonenumber.setText(number);
	}
}
